﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VehicleScale.Models;

namespace VehicleScale.EntityMappers
{
    public class VehicleScaleDetailMapper
    {
        #region Methods With Relation
        public static VehicleScaleDetailModel ToModel(VehicleScaleDetail entity)
        {
            if (entity == null) return null;

            VehicleScaleDetailModel model = new VehicleScaleDetailModel()
            {
                VehicleScaleDetailID = entity.VehicleScaleDetailID,
                VehicleScaleID = entity.VehicleScaleID,
                VehicleID = entity.VehicleID,
                FirstWeight = entity.FirstWeight,
                SecondWeight = entity.SecondWeight,
                ScaleTime1 = entity.ScaleTime1,
                ScaleTime2 = entity.ScaleTime2,
                EditedFirstWeight = entity.EditedFirstWeight,
                EditedSecondWeight = entity.EditedSecondWeight,
                NumberEdited = entity.NumberEdited,
                CreatedDate = entity.CreatedDate,
                VehicleScale = VehicleScaleMapper.ToModel(entity.VehicleScale, 0)
            };
            
            return model;
        }

        public static VehicleScaleDetail ToEntity(VehicleScaleDetail entity, VehicleScaleDetailModel model)
        {
            if (model == null) return null;

            entity.VehicleScaleDetailID = model.VehicleScaleDetailID;
            entity.VehicleScaleID = model.VehicleScaleID;
            entity.VehicleID = model.VehicleID;
            entity.FirstWeight = model.FirstWeight;
            entity.SecondWeight = model.SecondWeight;
            entity.ScaleTime1 = model.ScaleTime1;
            entity.ScaleTime2 = model.ScaleTime2;
            entity.EditedFirstWeight = model.EditedFirstWeight;
            entity.EditedSecondWeight = model.EditedSecondWeight;
            entity.NumberEdited = model.NumberEdited;
            entity.CreatedDate = model.CreatedDate;
 
            return entity;
        }
        #endregion

        #region Methods Without Relation
        // None process because it has not the children.
        #endregion
    }
}
